import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import path from 'path'
import eslint from 'vite-plugin-eslint'

const root = process.cwd()
const resolve = url => path.resolve(root, url)

export default defineConfig(() => {
  const conifg = {
    resolve: {
      alias: {
        '@': resolve('src')
      }
    },
    css: {
      postcss: {
        plugins: [
          {
            postcssPlugin: 'internal:charset-removal',
            AtRule: {
              charset: (atRule) => {
                if (atRule.name === 'charset') {
                  atRule.remove()
                }
              }
            }
          }
        ]
      },
      preprocessorOptions: {
        scss: {
          // additionalData: `
          //   $oss_url: "https://pic.datanode.cn/route-qiaohuicheng/integral-mp/test";
          //   @import "./src/styles/mixin.scss";
          // `
        }
      }
    },
    plugins: [
      uni(),
      eslint({ lintOnStart: true })
    ]
  }

  return conifg
})
